package 曾世昌12_8.zuoye15;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class test {
    public static void main(String[] args) throws Exception {
        System.out.println(a().toString());
    }

    public static List<Animal> a() throws Exception {
        List<Animal> ani = new ArrayList<>();
        List<String> str = FileUtils.readLines( new File( "E:\\untitled5\\src\\rc\\mxdx3_zhoumozuoye\\zuoye15\\dataAnimal.txt" ), "utf-8" );
        for (int i = 0; i < str.size(); i++) {
            String[] s = str.get( i ).split( " " );
            for (int i1 = 0; i1 < s.length; i1++) {
                Class<?> aClass = Class.forName( s[0] );
                if (s[0].contains( "Cat" )) {
                    Object o = aClass.getConstructor( String.class,String.class,String.class ).newInstance( s[1].split( "=" )[1], s[2].split( "=" )[1], s[3].split( "=" )[1] );
                    ani.add( (Animal) o );
                }
                if (s[0].contains( "Dog" )) {
                    Object o = aClass.getConstructor( String.class,String.class,int.class ).newInstance( s[1].split( "=" )[1], s[2].split( "=" )[1], s[3].split( "=" )[1] );
                    ani.add( (Animal) o );
                }
            }
        }
        return ani;
    }
}
